package cn.kgc.service.desktop;


import cn.kgc.dao.desktop.ScheduleDao;
import cn.kgc.pojo.Dict;
import cn.kgc.pojo.Schedule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;

@Service
public class ScheduleDaoServiceImpl implements ScheduleDaoService {

    @Autowired
    ScheduleDao scheduleDao;


    @Override
    public List<Schedule> queryAllAffairs(String keyword, Date dateStart, Date dateEnd, String contact, String type, String location, Integer currentPage, Integer pageSize, int userId) {
        return scheduleDao.queryAllAffairs('%' + keyword + '%', dateStart, dateEnd, contact, type, location, (currentPage - 1) * pageSize, pageSize, userId);
    }

    @Override
    public int queryAffairsCount(String keyword, Date dateStart, Date dateEnd, String contact, String type, String location, int userId) {
        return scheduleDao.queryAffairsCount('%' + keyword + '%', dateStart, dateEnd, contact, type, location, userId);
    }

    @Override
    public boolean addData(Schedule schedule) {
        if (scheduleDao.addData(schedule) > 0) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public boolean deleteData(int id) {
        if (scheduleDao.deleteData(id) > 0) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public Schedule queryUpdatedTarget(int id) {
        return scheduleDao.queryUpdatedTarget(id);
    }

    @Override
    public boolean updateData(int id, Schedule schedule) {
        if (scheduleDao.updateData(id, schedule) > 0) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public List<String> queryAllDateFromAffairs(int id) {
        return scheduleDao.queryAllDateFromAffairs(id);
    }

    @Override
    public List<Schedule> QueryAllData(String keyword) {
        return scheduleDao.QueryAllData('%' + keyword + '%');
    }

    /*Dict*/
    @Override
    public List<String> queryAllTypeInfo() {
        return scheduleDao.queryAllTypeInfo();
    }

    @Override
    public List<String> queryAllLocationInfo() {
        return scheduleDao.queryAllLocationInfo();
    }

    /*User*/

    @Override
    public List<String> queryAllContact() {
        return scheduleDao.queryAllContact();
    }

    @Override
    public List<Dict> queryAllDict() {
        return scheduleDao.queryAllDict();
    }

    @Override
    public List<String> queryDuration() {
        return scheduleDao.queryDuration();
    }

    @Override
    public List<Schedule> queryLeaveRequest(Integer id) {
        return scheduleDao.queryLeaveRequest(id);
    }

    @Override
    public int queryLeaveRequestCount(Integer id) {
        return scheduleDao.queryLeaveRequestCount(id);
    }

    @Override
    public int queryLeaveApplyCount(Integer id) {
        return scheduleDao.queryLeaveApplyCount(id);
    }


}
